﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Trangtrai.Controller.HistoryController;
using Trangtrai.Model;
using DevExpress.Web.ASPxGridView;

namespace Trangtrai.nhatky
{
    public partial class NormalReport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && !IsCallback)
            {
                bindingData();
            }
        }

        private void bindingData()
        {
            autoGenColumn();
        }

        public void autoGenColumn()
        {
            int index = 1;
            List<Cuan> cuanList = TomHisController.getCua();
            if (cuanList != null)
            {
                GridViewBandColumn bandCol = new GridViewBandColumn();
                foreach (Cuan cuan in cuanList)
                {
                    GridViewDataComboBoxColumn cuanData = new GridViewDataComboBoxColumn();

                    cuanData.FieldName = "cuanStatus" + index;
                    cuanData.Caption = "Lần " + index + "(" + cuan.time_cuan + "h)";
                    cuanData.PropertiesComboBox.ValueField = "cuanStatus";
                    cuanData.PropertiesComboBox.TextField = "cuanStatus";

                    bandCol.Columns.Add(cuanData); 

                    index++;
                }
                bandCol.Caption = "Kiểm tra vó";
                bandCol.VisibleIndex = 2;
                bandCol.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
                this.tomNormalReport.Columns.Add(bandCol);
            }
        }

        protected void tomHis_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewEditorEventArgs e)
        {

        }

        protected void tomHis_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {

        }

        protected void tomHis_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {

        }
    }
}